package binpacking.algorithms;

import java.util.ArrayList;
import java.util.List;

import sorting.algorithms.HeapSort;

import binpacking.model.BinContainer;
import binpacking.model.Block;

public class FirstFitDecreasing extends FirstFit {

	private HeapSort heapSort;
	
	public FirstFitDecreasing(List<Block> l, BinContainer binContainer,
			int binSize) {
		super(l, binContainer, binSize);
		
		heapSort = new HeapSort();
	}
	
	public void doFirstFitDecreasing() {
		ArrayList<Comparable> comparables = new ArrayList<Comparable>();
		
		for(Block block : blocks) {
			comparables.add(block);
		}
		
		heapSort.sortDesc(comparables);
		blocks.clear();
		
		for(Comparable comparable : comparables) {
			blocks.add((Block)comparable);
		}
		
		doFirstFit(); 
	}

}
